//-----------------------------------------------------
// logicfacade.cpp
//-----------------------------------------------------

/**
 * @file logicfacade.cpp
 * Implementation of the class that contains the game information.
 *
 * @see logic::ILogicFacade
 */

#include "logicfacade.h"

namespace logic {

	ILogicFacade::ILogicFacade() {}

	ILogicFacade::~ILogicFacade()
	{
		if (playing)
			end();
	}

	/***********************/
	/*		OBSERVERS      */
	/***********************/

	//bool ILogicFacade::addObserver(CPlayer::Observer* newObserver)
	//{
	//	// Specialize in the subclasses
	//	return false;
	//}

	//bool ILogicFacade::removeObserver(CPlayer::Observer* oldObserver)
	//{
	//	// Specialize in the subclasses
	//	return false;
	//}

	bool ILogicFacade::addObserver(CreationDestructionObserver* newObserver)
	{
		creatDestrObservers.push_back(newObserver);
		return true;
	}

	bool ILogicFacade::removeObserver(CreationDestructionObserver* oldObserver)
	{
		creatDestrObservers.remove(oldObserver);
		return true;
	}

	bool ILogicFacade::addObserver(GameEventsObserver* newObserver)
	{
		gameeventsObservers.push_back(newObserver);
		return true;
	}

	bool ILogicFacade::removeObserver(GameEventsObserver* oldObserver)
	{
		gameeventsObservers.remove(oldObserver);
		return true;
	}

	/********************/
	/*		EVENTS      */
	/********************/

	void ILogicFacade::emitStaticEntityCreated(CEntity *logicEntity)
	{
		std::list<CreationDestructionObserver*>::iterator it;
		it = creatDestrObservers.begin();

		while (it != creatDestrObservers.end())
		{
			(*it)->staticEntityCreated(this, logicEntity);
			++it;
		}
	}

} // namespace logic